package com.doroodo.sys.action;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.doroodo.base.action.BaseAction;
import com.doroodo.base.model.comboBox;
import com.doroodo.sys.model.*;
import com.doroodo.sys.service.*;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.ParentPackage;
@Controller
@ParentPackage(value="sys")   
@InterceptorRef("mydefault")
public class SyIconAction extends BaseAction{
	@Autowired
	private SyIconService syIconService;
	private SyIcon syIcon;
	
	public SyIcon getSyIcon(){
		return syIcon;
	}
	
	public void setSyIcon(SyIcon syIcon){
		this.syIcon=syIcon;
	}
	
	@Action("/sys/syIcon_Add")
	public void syIconAdd(){
		syIconService.saveOrUpdate(syIcon);
		writeMsg(this.ADD_SUC);
	}
	
	@Action("/sys/syIcon_List")
	public void syIconList(){
		this.writeJson(syIconService.dataGrid(this.getPage(), this.getRows(), this.getSearchName(), this.getSearchKey()));
	}
	
	@Action("/sys/syIcon_List_All")
	public void syIconListAll(){
		this.writeJson(syIconService.listAll());
	}
	
	@Action("/sys/syIcon_Get_ComboBox")
	public void syIconGetComboBox(){
		List<SyIcon> l = syIconService.listAll();
		List<comboBox> l_=new ArrayList<comboBox>();
		for(int i=0;i<l.size();i++){
			comboBox cb = new comboBox();
			cb.setId(l.get(i).getIconname());
			cb.setText(l.get(i).getIconname());
			l_.add(cb);
		}
		this.writeJson(l_);
	}
	
	@Action("/sys/syIcon_Delete")
	public void syIconDelete(){
		if(this.getIds().trim()=="")return;
		syIconService.delete(this.getIds());
		writeMsg(this.DEL_SUC);
	}
	
	@Action("/sys/syIcon_Update")
	public void syIconUpdate(){
		if(syIcon!=null) syIconService.saveOrUpdate(syIcon);
		writeMsg(this.EDIT_SUC);
	}
	
	@Action("/sys/syIcon_Excel")
	public void syIconExcel(){
		 String title = "Excel表";
		 List<Object> list = syIconService.dataGrid(this.getPage(), this.getRows(), this.getSearchName(), this.getSearchKey()).getRows();//获取数据
		 super.excel(title,list);
	}
	
	@Action("/sys/syIcon_Get_ByObj")  
	public void syIconGetByObj(){
		this.writeJson(syIconService.get(syIcon));
	}

}
